<?php
/**
 * Created by PhpStorm.
 * User: Dell
 * Date: 2018-12-10
 * Time: 14:56
 */

namespace app\admin\controller;


use app\common\model\MessageModel;

class Message extends Base
{
    public function index(){
        if(request()->isAjax()){

            $param = input('param.');

            $limit = $param['pageSize'];
            $offset = ($param['pageNumber'] - 1) * $limit;

            //条件查询
            $where = [];

            if (!empty($param['searchText'])) {
                $where['mess_name'] = ['like', '%' . $param['searchText'] . '%'];
            }

            $message = new MessageModel();
            $selectResult = $message->getMessageByWhere($where, $offset, $limit);


            $return['total'] = $message->getAllMessage($where);  // 总数据
            $return['rows'] = $selectResult;

            return json($return);
        }
        return $this->fetch();
    }
}